﻿using Ex5.InsertionSort;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Ex5.TestInsertionSort
{
    [TestClass()]
    public class InsertionSortAlgorithmTest
    {
        [TestMethod()]
        public void InsertionSortAlgorithmConstructorTest()
        {
            int[] emptyArray = new int[] { };
            InsertionSortAlgorithm target = new InsertionSortAlgorithm(emptyArray);
        }

        [TestMethod()]
        public void InsertionSortAlgorithmEmptyArrayTest()
        {
            int[] emptyArray = new int[] { };
            InsertionSortAlgorithm target = new InsertionSortAlgorithm(emptyArray);
            target.InsertionSort();
            int[] newArray = target.Array;
            CollectionAssert.AreEqual(emptyArray, newArray);
        }

        [TestMethod()]
        public void InsertionSortAlgorithmPossitiveNumbersTest()
        {
            int[] startArray = new int[] {2,6,1 };
            InsertionSortAlgorithm target = new InsertionSortAlgorithm(startArray);
            target.InsertionSort();
            int[] resultArray = new int[] {1,2,6};
            CollectionAssert.AreEqual(resultArray, startArray);
        }

        [TestMethod()]
        public void InsertionSortAlgorithmNegativeNumbersTest()
        {
            int[] startArray = new int[] { 2, -6, 0 };
            InsertionSortAlgorithm target = new InsertionSortAlgorithm(startArray);
            target.InsertionSort();
            int[] resultArray = new int[] { -6, 0, 2 };
            CollectionAssert.AreEqual(resultArray, startArray);
        }

        [TestMethod()]
        public void InsertionSortAlgorithmZeroTest()
        {
            int[] startArray = new int[] { 0,0,0 };
            InsertionSortAlgorithm target = new InsertionSortAlgorithm(startArray);
            target.InsertionSort();
            int[] resultArray = new int[] { 0, 0, 0 };
            CollectionAssert.AreEqual(resultArray, startArray);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException),"Array can't be null!")]
        public void InsertionSortAlgorithmNullArray()
        {
            InsertionSortAlgorithm target = new InsertionSortAlgorithm(null);
        }
    }
}
